angular.module("controller.user", [ "services", "ui.router" ]).controller(
		"userCtrl",
		[
				"$scope",
				"apiService",
				"alertManager",
				function($scope, apiService, alertManager) {
					$scope.data = {};
					$scope.data.registerAdmin = function() {
						apiService.registerAdmin($scope.data.username,
								$scope.data.password).then(function() {
							alertManager.addAlert("success", "成功創建管理員");
						}, function(response) {
							console.log(response);
							alertManager.addAlert("danger", "無法創建管理員");
						});
					};
					$scope.data.registerAgent = function() {
						apiService.registerAgent($scope.data.agentUsername,
								$scope.data.agentPassword).then(function() {
							alertManager.addAlert("success", "成功創建經理人");
						}, function(response) {
							console.log(response);
							alertManager.addAlert("danger", "無法創建經理人, 經理人名稱須長度大於4");
						});
					};
				} ])
